package com.github.prontera.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.prontera.domain.ClientInvitation;
import com.github.prontera.persistence.ClientInvitationMapper;
import com.github.prontera.persistence.CrudMapper;
import com.github.prontera.util.Page;

/**
 * 用户邀请表
 */
@Service
public class ClientInvitationService extends CrudServiceImpl<ClientInvitation>{
    
    @Autowired
    private ClientInvitationMapper clientInvitationMapper;
    
  	@Autowired
    public ClientInvitationService(CrudMapper<ClientInvitation> mapper) {
        super(mapper);
    }
  	
  	public List<ClientInvitation> findClient(ClientInvitation clientInvitation){
  		return clientInvitationMapper.findClient(clientInvitation);
  	}
  	
	public Page<ClientInvitation> invitationPage(ClientInvitation clientInvitation) {
		long count = clientInvitationMapper.invitationCount(clientInvitation);
		Page<ClientInvitation> page = new Page<ClientInvitation>(clientInvitation.getPageIndex(), clientInvitation.getPageSize());
		page.setData(clientInvitationMapper.findClient(clientInvitation));
		page.setTotalCount(count);
		return page;
	}
	
	/**
	 * 查询邀请列表
	 */
	public Page<ClientInvitation> pageList(ClientInvitation clientInvitation) {
		long count = clientInvitationMapper.count(clientInvitation);
		Page<ClientInvitation> page = new Page<ClientInvitation>(clientInvitation.getPageIndex(), clientInvitation.getPageSize());
		page.setData(clientInvitationMapper.findClient2(clientInvitation));
		page.setTotalCount(count);
		return page;
	}
}
